home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / cdrtools-1.10 / libfile / file.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-06  |  4.9 KB  |  157 lines

  1. /*
  2.  * file.h - definitions for file(1) program
  3.  * @(#)$Id: file.h,v 1.25 1997/01/15 19:28:35 christos Exp $
  4.  *
  5.  * Copyright (c) Ian F. Darwin, 1987.
  6.  * Written by Ian F. Darwin.
  7.  *
  8.  * This software is not subject to any license of the American Telephone
  9.  * and Telegraph Company or of the Regents of the University of California.
  10.  *
  11.  * Permission is granted to anyone to use this software for any purpose on
  12.  * any computer system, and to alter it and redistribute it freely, subject
  13.  * to the following restrictions:
  14.  *
  15.  * 1. The author is not responsible for the consequences of use of this
  16.  *    software, no matter how awful, even if they arise from flaws in it.
  17.  *
  18.  * 2. The origin of this software must not be misrepresented, either by
  19.  *    explicit claim or by omission.  Since few users ever read sources,
  20.  *    credits must appear in the documentation.
  21.  *
  22.  * 3. Altered versions must be plainly marked as such, and must not be
  23.  *    misrepresented as being the original software.  Since few users
  24.  *    ever read sources, credits must appear in the documentation.
  25.  *
  26.  * 4. This notice may not be removed or altered.
  27.  */
  28.  
  29. #ifndef __file_h__
  30. #define __file_h__
  31.  
  32. #ifndef __BEOS__
  33. typedef int int32;
  34. typedef unsigned int uint32;
  35. #else
  36. #include <SupportDefs.h>
  37. #endif /* __BEOS__ */
  38.  
  39. #ifndef HOWMANY
  40. # define HOWMANY 8192        /* how much of the file to look at */
  41. #endif
  42. #define MAXMAGIS 1000        /* max entries in /etc/magic */
  43. #define MAXDESC    50        /* max leng of text description */
  44. #define MAXstring 32        /* max leng of "string" types */
  45.  
  46. struct magic {
  47.     short flag;        
  48. #define INDIR    1        /* if '>(...)' appears,  */
  49. #define    UNSIGNED 2        /* comparison is unsigned */
  50. #define ADD    4        /* if '>&' appears,  */
  51.     short cont_level;    /* level of ">" */
  52.     struct {
  53.         char type;    /* byte short long */
  54.         int32 offset;    /* offset from indirection */
  55.     } in;
  56.     int32 offset;        /* offset to magic number */
  57.     unsigned char reln;    /* relation (0=eq, '>'=gt, etc) */
  58.     char type;        /* int, short, long or string. */
  59.     char vallen;        /* length of string value, if any */
  60. #define             BYTE    1
  61. #define                SHORT    2
  62. #define                LONG    4
  63. #define                STRING    5
  64. #define                DATE    6
  65. #define                BESHORT    7
  66. #define                BELONG    8
  67. #define                BEDATE    9
  68. #define                LESHORT    10
  69. #define                LELONG    11
  70. #define                LEDATE    12
  71.     union VALUETYPE {
  72.         unsigned char b;
  73.         unsigned short h;
  74.         uint32 l;
  75.         char s[MAXstring];
  76.         unsigned char hs[2];    /* 2 bytes of a fixed-endian "short" */
  77.         unsigned char hl[4];    /* 2 bytes of a fixed-endian "long" */
  78.     } value;        /* either number or string */
  79.     uint32 mask;    /* mask before comparison with value */
  80.     char nospflag;        /* supress space character */
  81.     char desc[MAXDESC];    /* description */
  82. };
  83.  
  84. #include <stdio.h>    /* Include that here, to make sure __P gets defined */
  85.  
  86. #ifndef __P
  87. # if __STDC__ || __cplusplus
  88. #  define __P(a) a
  89. # else
  90. #  define __P(a) ()
  91. #  define const
  92. # endif
  93. #endif
  94.  
  95. extern int   init_magic        __P((char *));
  96. extern int   ascmagic        __P((unsigned char *, int));
  97. /*extern void  error        __P((const char *, ...));*/
  98. extern void  ckfputs        __P((const char *, FILE *));
  99. struct stat;
  100. extern int   fsmagic        __P((const char *, struct stat *));
  101. extern int   is_compress    __P((const unsigned char *, int *));
  102. extern int   is_tar        __P((unsigned char *, int));
  103. extern void  magwarn        __P((const char *, ...));
  104. extern void  mdump        __P((struct magic *));
  105. extern char *get_magic_magic    __P((const char *));
  106. extern void  showstr        __P((FILE *, const char *, int));
  107. extern char *softmagic        __P((unsigned char *, int));
  108. extern int   tryit        __P((unsigned char *, int, int));
  109. extern int   zmagic        __P((unsigned char *, int));
  110. extern void  ckfprintf        __P((FILE *, const char *, ...));
  111. #ifndef __BEOS__
  112. extern uint32 signextend    __P((struct magic *, uint32));
  113. #endif /* __BEOS__ */
  114. extern int internatmagic    __P((unsigned char *, int));
  115. extern void tryelf        __P((int, char *, int));
  116.  
  117.  
  118. extern int errno;        /* Some unixes don't define this..    */
  119.  
  120. extern char *progname;        /* the program name             */
  121. extern char *magicfile;        /* name of the magic file        */
  122. extern int lineno;        /* current line number in magic file    */
  123.  
  124. extern struct magic *magic;    /* array of magic entries        */
  125. extern int nmagic;        /* number of valid magic[]s         */
  126.  
  127.  
  128. extern int debug;        /* enable debugging?            */
  129. extern int zflag;        /* process compressed files?        */
  130. extern int lflag;        /* follow symbolic links?        */
  131.  
  132. extern int optind;        /* From getopt(3)            */
  133. extern char *optarg;
  134.  
  135. #if defined(sun) || defined(__sun__) || defined (__sun)
  136. # if defined(__svr4) || defined (__SVR4) || defined(__svr4__)
  137. #  define SOLARIS
  138. # else
  139. #  define SUNOS
  140. # endif
  141. #endif
  142.  
  143.  
  144. #if !defined(__STDC__) || defined(SUNOS) || defined(__convex__)
  145. extern int sys_nerr;
  146. extern char *sys_errlist[];
  147. #define strerror(e) \
  148.     (((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
  149. #define strtoul(a, b, c)    strtol(a, b, c)
  150. #endif
  151.  
  152. #ifndef MAXPATHLEN
  153. #define    MAXPATHLEN    512
  154. #endif
  155.  
  156. #endif /* __file_h__ */
  157.